#include<algorithm>
#include<iterator>
#include<map>

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
            map<int,int>::iterator loc;
            map<int,int>  num_map;  
            vector<int> temp;
            int lose;
            for(int j = 0;j<nums.size();j++)
            {
                lose=target-nums[j];
                loc = num_map.lower_bound(lose);
                if(loc!= num_map.end() && (*loc).first==lose)
                {
                    temp.push_back((*loc).second);
                    temp.push_back(j);
                }
                num_map.emplace(nums[j],j);
            }
          
           
            return temp;
    }
};
